//
//  CXDiscoverViewModel.m
//  喜马拉雅FM
//
//  Created by hcios on 2017/8/31.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "CXDiscoverViewModel.h"
#import "CXDiscoverNetManager.h"

@implementation CXDiscoverViewModel

-(void)getDataCompletionHandle:(void (^)(NSError *))completed {
    self.dataTask = [CXDiscoverNetManager getDiscoverIntroduceCompletionHandle:^(CXDiscoverModel * responseObject, NSError *error) {
        self.model = responseObject;
        completed(error);
    }];
}


-(NSInteger)cellCount {
    return self.model.list.count;
}


-(NSInteger)cellCount:(NSInteger)section {
    return self.model.list[section].list.count;
}


/** 图标接口*/
-(NSURL *)iconURLWithIndex: (NSInteger)index Section:(NSInteger)section{
    NSString * path = self.model.list[section].list[index].coverPath;
    return [NSURL URLWithString:path];
}

/** title接口*/
-(NSString *)titleWithIndex:(NSInteger)index Section:(NSInteger)section{
    return self.model.list[section].list[index].title;
}

/** 副标题 */
-(NSString *)subTitleWithIndex:(NSInteger)index Section:(NSInteger)section{
    return self.model.list[section].list[index].subtitle;
    
}

/** url*/
-(NSURL * )URLWithIndex:(NSInteger)index WithSection:(NSInteger)section{
    NSString * path = self.model.list[section].list[index].url;
    return [NSURL URLWithString:path];
    
}



@end
